package cn.ad.server.web.spring.model.sts;

import cn.ad.server.web.spring.model.AdRequest;
import cn.ad.server.web.spring.service.actions.context.AdContext;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * Adserver自有Server2Server协议请求对象
 * 
 * @author dongbin.yu
 * @from 2016-05-18
 * @since V1.0
 */
public class STSAdRequest extends AdRequest {

	/**
	 * 广告请求中的印象信息
	 */
	private Impression[] impression;

	/**
	 * 广告请求中的用户设备信息
	 */
	private Device device;

	/**
	 * 广告请求当前系统时间戳
	 */
	private int ts;

	/**
	 * 广告请求协议版本号
	 */
	private float version;

	@JsonProperty("extend_data")
	private String extendData;

	@JsonProperty("debug_mode")
	private boolean debugMode;

	private AdContext adContext;

	public boolean isDebugMode() {
		return debugMode;
	}

	public void setDebugMode(boolean debugMode) {
		this.debugMode = debugMode;
	}

	public AdContext getAdContext() {
		return adContext;
	}

	public void setAdContext(AdContext adContext) {
		this.adContext = adContext;
	}

	/**
	 * 广告位对象 see Falcon移动广告Server对接协议V1.0.7.pdf
	 */
	public static class Impression {

		private int aid;

		private int width;

		private int height;

		private String keywords;

		@JsonProperty("page_index")
		private int pageIndex;

		@JsonProperty("page_size")
		private int pageSize;

		public String getKeywords() {
			return keywords;
		}

		public void setKeywords(String keywords) {
			this.keywords = keywords;
		}

		public int getAid() {
			return aid;
		}

		public void setAid(int aid) {
			this.aid = aid;
		}

		public int getWidth() {
			return width;
		}

		public void setWidth(int width) {
			this.width = width;
		}

		public int getHeight() {
			return height;
		}

		public void setHeight(int height) {
			this.height = height;
		}

		public int getPageIndex() {
			return pageIndex;
		}

		public void setPageIndex(int pageIndex) {
			this.pageIndex = pageIndex;
		}

		public int getPageSize() {
			return pageSize;
		}

		public void setPageSize(int pageSize) {
			this.pageSize = pageSize;
		}

		@Override
		public String toString() {
			return ToStringBuilder.reflectionToString(this);
		}
	}

	/**
	 * 设备对象 see Falcon移动广告Server对接协议V1.0.3.pdf
	 */
	public static class Device {

		/**
		 * 用户终端的 IMEI，15 位数字，md5 加密
		 */
		private String imei;

		/**
		 * 原始imei，建议和imei一起传给sever端
		 */
		private String imeiori;

		/**
		 * 用户终端的 eth0 接口的 MAC 地址（大写去除冒号分隔符）， md5 加密
		 */
		private String mac;

		/**
		 * 原始mac，建议和mac一起传给sever端
		 */
		private String macori;

		/**
		 * 用户终端的 eth0 接口的 MAC 地址（大写且保留冒号分隔符），md5 加密
		 */
		private String mac1;

		/**
		 * IOS IDFA 适用于 IOS6 及以上，md5 加密
		 */
		private String idfa;

		/**
		 * 原始idfa，建议和idfa一起传给sever端
		 */
		private String idfaori;

		/**
		 * Android Advertising ID，md5 加密
		 */
		private String aaid;

		/**
		 * Android ID，仅适用于 Android 设备，md5 加密
		 */
		private String anid;

		/**
		 * 原始Android ID，建议和anid一起传给sever端
		 */
		private String anidori;

		/**
		 * IOS UDID，md5 加密
		 */
		private String udid;

		/**
		 * Windows Phone 用户终端的 DUID，md5 加密
		 */
		private String duid;

		/**
		 * 设备品牌
		 */
		private String brand;

		/**
		 * 设备型号
		 */
		private String platform;

		/**
		 * 操作系统 0：未知 1：android 2：ios 3：windows
		 */
		private int os;

		@JsonProperty("os_version")
		private String osVersion;

		@JsonProperty("device_size")
		private String deviceSize;

		private int network;

		private int operator;

		private float longitude;

		private float latitude;

		@JsonProperty("screen_orientation")
		private int screenOrientation;

		private String ip;

		public String getImei() {
			return imei;
		}

		public void setImei(String imei) {
			this.imei = imei;
		}

		public String getMac() {
			return mac;
		}

		public void setMac(String mac) {
			this.mac = mac;
		}

		public String getMac1() {
			return mac1;
		}

		public void setMac1(String mac1) {
			this.mac1 = mac1;
		}

		public String getIdfa() {
			return idfa;
		}

		public void setIdfa(String idfa) {
			this.idfa = idfa;
		}

		public String getAaid() {
			return aaid;
		}

		public void setAaid(String aaid) {
			this.aaid = aaid;
		}

		public String getAnid() {
			return anid;
		}

		public void setAnid(String anid) {
			this.anid = anid;
		}

		public String getUdid() {
			return udid;
		}

		public void setUdid(String udid) {
			this.udid = udid;
		}

		public String getDuid() {
			return duid;
		}

		public void setDuid(String duid) {
			this.duid = duid;
		}

		public String getBrand() {
			return brand;
		}

		public void setBrand(String brand) {
			this.brand = brand;
		}

		public String getPlatform() {
			return platform;
		}

		public void setPlatform(String platform) {
			this.platform = platform;
		}

		public int getOs() {
			return os;
		}

		public void setOs(int os) {
			this.os = os;
		}

		public String getOsVersion() {
			return osVersion;
		}

		public void setOsVersion(String osVersion) {
			this.osVersion = osVersion;
		}

		public String getDeviceSize() {
			return deviceSize;
		}

		public void setDeviceSize(String deviceSize) {
			this.deviceSize = deviceSize;
		}

		public int getNetwork() {
			return network;
		}

		public void setNetwork(int network) {
			this.network = network;
		}

		public int getOperator() {
			return operator;
		}

		public void setOperator(int operator) {
			this.operator = operator;
		}

		public float getLongitude() {
			return longitude;
		}

		public void setLongitude(float longitude) {
			this.longitude = longitude;
		}

		public float getLatitude() {
			return latitude;
		}

		public void setLatitude(float latitude) {
			this.latitude = latitude;
		}

		public int getScreenOrientation() {
			return screenOrientation;
		}

		public void setScreenOrientation(int screenOrientation) {
			this.screenOrientation = screenOrientation;
		}

		public String getIp() {
			return ip;
		}

		public void setIp(String ip) {
			this.ip = ip;
		}

		/**
		 * @return the imeiori
		 */
		public String getImeiori() {
			return imeiori;
		}

		/**
		 * @param imeiori
		 *            the imeiori to set
		 */
		public void setImeiori(String imeiori) {
			this.imeiori = imeiori;
		}

		/**
		 * @return the macori
		 */
		public String getMacori() {
			return macori;
		}

		/**
		 * @param macori
		 *            the macori to set
		 */
		public void setMacori(String macori) {
			this.macori = macori;
		}

		/**
		 * @return the idfaori
		 */
		public String getIdfaori() {
			return idfaori;
		}

		/**
		 * @param idfaori
		 *            the idfaori to set
		 */
		public void setIdfaori(String idfaori) {
			this.idfaori = idfaori;
		}

		/**
		 * @return the anidori
		 */
		public String getAnidori() {
			return anidori;
		}

		/**
		 * @param anidori
		 *            the anidori to set
		 */
		public void setAnidori(String anidori) {
			this.anidori = anidori;
		}

		@Override
		public String toString() {
			return ToStringBuilder.reflectionToString(this);
		}
	}

	public Impression[] getImpression() {
		return impression;
	}

	public void setImpression(Impression[] impression) {
		this.impression = impression;
	}

	public Device getDevice() {
		return device;
	}

	public void setDevice(Device device) {
		this.device = device;
	}

	public int getTs() {
		return ts;
	}

	public void setTs(int ts) {
		this.ts = ts;
	}

	public float getVersion() {
		return version;
	}

	public void setVersion(float version) {
		this.version = version;
	}

	public String getExtendData() {
		return extendData;
	}

	public void setExtendData(String extendData) {
		this.extendData = extendData;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
